/*++****************************************************************************
*
*	Name: flash.h
*   
*	Description:	This module provides defines and structures for the 
*					PIC32 flash memory read/write routines to allow a portion
*					of dynamically written memory to survive power off/on.
*
*	Revision History:
*	Date	Who	Comments	
*	------	---	---------------------------------------------------------------
*	101128	RLP	Created
****************************************************************************--*/

#ifndef FLASH_H
#define FLASH_H


/******************************************************************************
								CONSTANTS AND MACROS
******************************************************************************/

#define FLASH_SIZE 	4096	// set to multiple of 4096 for PIC NVM* code compatibility

// MACROS
     
/******************************************************************************
								TYPEDEFS and STRUCTS
******************************************************************************/

// flash memory layout: total length must not exceed FLASH_SIZE

typedef struct
{
	char	sigGenCfg[80];				// signal generator config
} FlashMap;

typedef struct
{
	union
	{
	UINT8 		byte[FLASH_SIZE];		// all of 
	FlashMap	map;					// laid out areas for different use
	};
} FlashMem;


/******************************************************************************
								FUNCTION PROTOTYPES
******************************************************************************/

extern INT16 FlashRead( UINT16	flashMemOffset,	// offset into flash mem area
						UINT16	len,			// byte length to read
						UINT8	*outBuf );		// out buffer to recv data read

extern INT16 FlashWrite( UINT16	flashMemOffset,	// offset into flash mem area
						 UINT16	len,			// byte length to write
						 UINT8	*inBuf );		// in buffer to write

/******************************************************************************
								ERROR CODES
******************************************************************************/

#define FLASH_SUCCESS					0			// success
#define FLASH_BAD_LEN					1			// invalid length param
#define FLASH_NVM_PGM_ERR				2			// NVMProgram retnd an error

#endif
